#
# This file is a part of the open-eBackup project.
# This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
# If a copy of the MPL was not distributed with this file, You can obtain one at
# http://mozilla.org/MPL/2.0/.
#
# Copyright (c) [2024] Huawei Technologies Co.,Ltd.
#
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
#

from enum import Enum


class StorageType(int, Enum):
    DORADO = 0


class StorageVersion(int, Enum):
    STORAGE_V6 = 0


class DeviceType:
    DORADO_V6 = "DoradoV6"


class AgentScene(int, Enum):
    EXTERNAL = 0  # 外置代理
    INTERNAL = 1  # 内置代理


class HttpConfig:
    HTTP_TIME_OUT: int = 30
    MAX_CACHE_CONNECTION: int = 1
    MAX_HTTP_RETRIES: int = 3


class HttpConfigOnce:
    MAX_HTTP_RETRIES: int = 0


class AssociateObjectType:
    LUN: int = 11
    HOST: int = 21
    SNAPSHOT: int = 27
    LUN_GROUP: int = 256
    PROTECT_GROUP: int = 57846
    SNAPSHOT_CONSISTENCY_GROUP: int = 57646


class ReturnCode(int):
    SUCCESS = 0
    FAILED = -1
    NOT_EXIST = -2


class SnapshotHealthStatus(int, Enum):
    NORMAL = 1
    ABNORMAL = 2
    WRITE_PROTECT = 15


class SnapshotRunningStatus(int, Enum):
    UNKNOWN = 0
    ACTIVATED = 43
    ROLLING = 44
    INACTIVATED = 45
    INITIALING = 53
    DELETING = 106


class HyperPairAccessState:
    ACCESS_FORBIDDEN = '1'
    READ_ONLY = '2'
    READ_WRITE = '3'


# storage's error code
class StorageErrorCode(int):
    FILE_SYSTEM_ALREADY_EXIST = 1077948993
    NFS_SHARE_ALREADY_EXIST = 1077939724
    NFS_ALIAS_EXIST = 1077940485
    CIFS_SHARE_ALREADY_EXIST = 1077939715
    ALREADY_IN_WHITE = 1077939727
    SHARE_CLIENT_NOT_EXIST = 1077939728
    FILE_SYSTEM_NOT_EXIST = 1077939726
    FILE_SYSTEM_ID_NOT_EXIST = 1073752065
    FILE_SYSTEM_SNAPSHOT_EXIST = 1073754142
    HOST_LUN_MAPPING_EXIST = 1073804588
    HOST_EXIST = 1077948993
    NOT_NEED_ADD_NUMBER = 1073947144
    SNAPSHOT_NOT_EXIST = 1077937872
    FS_SNAPSHOT_NOT_EXIST = 1073754118
    WINDOWS_USER_NOT_EXIST = 37749698
    WINDOWS_USER_PASSWORD_SAME = 37749700
    NO_USER_PERMISSION = 1077949058
    AUTH_IP_INCONSISTENCY = 1073793620
    LUN_GROUP_HOST_MAPPING_NOT_EXIST = 1073804589
    LUN_HOST_MAPPING_NOT_EXIST = 1073804587
    LUN_HOST_MAPPING_EXIST = 1073804588
    LUN_GROUP_HOST_MAPPING_EXIST = 1073804590
    FC_AND_ISCSI_NOT_EXIST = 1077948996
    REMOTE_DEVICE_NOT_EXIST = 37100137
    REMOTE_USER_NOT_EXIST = 1077949057
    RETURN_SNAP_REACH_FILE_SYSTEM_MAX_NUM = 1073754137
    RETURN_SNAP_REACH_ENTIRE_SYSTEM_MAX_NUM = 1073754138
    RETRUN_SNAP_REACH_PARENT_FS_MAX_NUM = 1073844275
    DTREE_NAME_IS_EXIST = 1077955353
    DTREE_NOT_EXIST = 1077955336
    DTREE_REACH_MAX = 1077955339
    QTREE_REACH_MAX = 1077955083
    DTREE_DIR_EXIST = 1077955354
    FS_ALREADY_EXIST_QOS = 1073810732
    STORAGE_POOL_NOT_EXIST = 1077949965
    RETURN_DTREE_FS_NOT_EXIST = 1077955329
    PARAMETER_ERROR = 50331651
    UNAUTH = -401
    DATA_TURBO_USER_NOT_EXIST = 1077949057
    DATA_TURBO_USER_ALREADY_EXIST = 1077949059
    DATA_TURBO_SHARE_ALREADY_EXIST = 1077941008
    DATA_TURBO_SHARE_NOT_EXIST = 1077941015
    DATA_TURBO_SHARE_DELETE_NOT_EXIST = 1077941000
    DATA_TURBO_USER_OFFLINE = 1077949069
    DATA_TURBO_SHARE_PERMISSION_ALREADY_EXIST = 1077939718
    GLOBAL_SECURE_COMPLIANCE_CLOCK_NOT_EXIST = 1073752089
    GLOBAL_SECURE_COMPLIANCE_CLOCK_ALREADY_EXIST = 1073752094
    NFS_SHARE_CLIENT_NOT_EXIST = 1077939726
    CIFS_SHARE_CLIENT_NOT_EXIST = 1077939717


StorageNoNeedRetryErrorCode = (
    StorageErrorCode.FILE_SYSTEM_ALREADY_EXIST, StorageErrorCode.NFS_SHARE_ALREADY_EXIST,
    StorageErrorCode.CIFS_SHARE_ALREADY_EXIST, StorageErrorCode.ALREADY_IN_WHITE,
    StorageErrorCode.FILE_SYSTEM_NOT_EXIST, StorageErrorCode.FILE_SYSTEM_SNAPSHOT_EXIST,
    StorageErrorCode.FS_SNAPSHOT_NOT_EXIST, StorageErrorCode.HOST_LUN_MAPPING_EXIST,
    StorageErrorCode.FILE_SYSTEM_ID_NOT_EXIST, StorageErrorCode.WINDOWS_USER_NOT_EXIST,
    StorageErrorCode.HOST_EXIST, StorageErrorCode.SNAPSHOT_NOT_EXIST, StorageErrorCode.NOT_NEED_ADD_NUMBER,
    StorageErrorCode.LUN_HOST_MAPPING_EXIST, StorageErrorCode.LUN_GROUP_HOST_MAPPING_NOT_EXIST,
    StorageErrorCode.FC_AND_ISCSI_NOT_EXIST, StorageErrorCode.LUN_GROUP_HOST_MAPPING_EXIST,
    StorageErrorCode.LUN_HOST_MAPPING_NOT_EXIST, StorageErrorCode.RETURN_SNAP_REACH_FILE_SYSTEM_MAX_NUM,
    StorageErrorCode.RETURN_SNAP_REACH_ENTIRE_SYSTEM_MAX_NUM, StorageErrorCode.RETRUN_SNAP_REACH_PARENT_FS_MAX_NUM,
    StorageErrorCode.DTREE_NOT_EXIST, StorageErrorCode.DTREE_NAME_IS_EXIST, StorageErrorCode.FS_ALREADY_EXIST_QOS,
    StorageErrorCode.SHARE_CLIENT_NOT_EXIST, StorageErrorCode.RETURN_DTREE_FS_NOT_EXIST,
    StorageErrorCode.PARAMETER_ERROR, StorageErrorCode.DATA_TURBO_USER_NOT_EXIST,
    StorageErrorCode.DATA_TURBO_USER_ALREADY_EXIST, StorageErrorCode.DATA_TURBO_SHARE_ALREADY_EXIST,
    StorageErrorCode.DATA_TURBO_SHARE_NOT_EXIST, StorageErrorCode.DATA_TURBO_SHARE_DELETE_NOT_EXIST,
    StorageErrorCode.DATA_TURBO_USER_OFFLINE, StorageErrorCode.DATA_TURBO_SHARE_PERMISSION_ALREADY_EXIST,
    StorageErrorCode.GLOBAL_SECURE_COMPLIANCE_CLOCK_NOT_EXIST, StorageErrorCode.NFS_SHARE_CLIENT_NOT_EXIST,
    StorageErrorCode.CIFS_SHARE_CLIENT_NOT_EXIST, StorageErrorCode.NFS_ALIAS_EXIST,
    StorageErrorCode.DTREE_DIR_EXIST
)
